This invention relates generally to software for displaying image data, and more specifically to rotating image data.
The rapid evolution of personal computer technology continues to produce personal computers that are smaller, cheaper and faster than their predecessors. Where computers once occupied entire rooms, they are now small enough to fit in the palm of the hand, hence the name xe2x80x9cPalm-size PCsxe2x80x9d.
The reduced size of the Palm-size PC means that certain sacrifices need to be made. For example, a typical Palm-size PC does not have fixed or removable disk drives such as hard disk, floppy disk, CD-ROM or DVD-ROM drives, with the persistent storage of a typical Palm-size PC comprising flash memory or volatile memory with a battery refresh. In addition, the amount of RAM in the typical Palm-size PC is also limited, resulting in specialized operating systems capable of running in the resource limited environment of the Palm-size PC. An example of such an operating system is the Windows CE(trademark) operating system from Microsoft Corporation. Applications running on the Palm-size PC must also be capable of running in the resource limited environment described above. Applications running on the Palm-size PC are typically specialized versions of applications available on the bigger siblings of the Palm-size PC, such as calendar programs, personal information managers, calculators and the like.
Display size, resolution and color capability are other aspects that are affected by the reduced size of the Palm-size PC. The typical display of a standard PC has a diagonal length of between 14xe2x80x3 and 21xe2x80x3, a resolution ranging from 640xc3x97480 pixels to over 1280xc3x971024 pixels, and is capable of displaying over sixteen million colors. In contrast, the typical Palm-size PC has a liquid crystal diode (LCD) display with a diagonal length of between 3.4xe2x80x3 and 3.9xe2x80x3, a resolution of 240xc3x97320 pixels, and is capable of a displaying four gray scale levels.
Designers have found that in the reduced size environment of a Palm-size PC, a portrait mode display is preferable to landscape mode. A portrait mode display is one that is taller than it is wide, i.e. the screen is 240xc3x97320 pixels. However, portrait LCDs typically are not as bright as landscape LCDs, and in addition, portrait LCDs typically exhibit an undesirable flicker.
Two solutions to the above-described flicker and brightness problems have been implemented in previous systems. The first solution uses what is known in the art as a dual-scan portrait LCD. Dual-scan LCDs are brighter and are able to provide a display that is typically flicker free. In addition the dual-scan LCD has the advantage that the display device interface used by a portrait mode application can avoid display driver overhead by writing directly to the dual-scan portrait LCD, since the display buffer and the display device orientation are the same. A significant disadvantage to the dual-scan LCD is that it costs approximately twice as much as a standard landscape LCD.
The second solution is to provide the Palm-size PC with a landscape LCD that has been physically rotated ninety degrees. In this solution, the system must maintain an intermediate screen buffer of pixels that must be rotated ninety degrees prior to insertion in the display buffer, thereby providing a portrait mode emulation using a landscape LCD. The advantage of this solution is that an acceptable display quality can be achieved with a lower cost of goods. A disadvantage with this solution is that direct screen writes to the display buffer are not possible, because the physical orientation of the screen does not match the orientation of the display buffer. This results in increased demands on the CPU and memory in a system with limited resources.
Previous systems have used various mechanisms to rotate image data in the screen buffer. In one system, the pixels are rotated one by one. In this system, the bits representing the color or gray scale level for an individual pixel in the screen buffer are extracted from the original memory location in the screen buffer and placed into a temporary byte. A memory location in the display buffer in which to place the pixel is then determined. The new location will reflect the ninety degree rotation. The rotated pixel value is written to image data comprising the display buffer by setting the appropriate bits in the new memory location with the bits from the temporary byte. In a second system, a table lookup scheme, as is known in the art, is used to rotate the screen.
A major disadvantage with both systems is that each pixel value in the screen buffer is converted to a byte value before it is moved from the internal screen buffer into the proper location in the display buffer. This is due to the fact that to implement the methods described above, various operations such as shifting and bit masking must be performed on a single pixel value. The smallest unit that most computers, including Palm-size PCs, can operate on is a byte. As a result, multiple CPU cycles are used to rotate each pixel using the mechanisms in the above-described systems. This results in increased demand for CPU and power resources in a machine that typically has limited resources.
Therefore, there is a need for a more efficient system to perform a ninety-degree rotation of image data. There is a need for such a system which consumes less CPU and power resources to perform such rotations.
Rotation of image data comprising a screen buffer by ninety degrees is accomplished by dividing an area within the image data into a plurality of square pixel regions, rotating each of the squares, and writing the squares to a rotated image data buffer. The rotated image data buffer may comprise a display buffer. The system includes a graphics device driver that implements the rotation and maintains the display buffer. One version of the computerized system includes an operating system providing a graphics interface library, and a graphics interface buffer maintained by the graphics interface library. In this system, the graphics interface buffer contains the image data prior to rotation.
The method used to rotate the area divides the area into a square region of pixels, where each pixel has a number of bits specifying a color or gray scale level. The size of a side of the square region is determined by the word size of the computer and the number of bits specifying the color. For each row in the square area, one or more bytes representing the row are expanded by multiplying by an expansion constant determined by the word size and the number of bits specifying the color. Extraneous bits are removed by performing a logical AND of the word with a filter constant determined by the number of bits specifying the color. Finally, the word is left shifted by a number of places determined by the index of the row in the square and the number of bits specifying the color. The result is placed in one of a plurality of expansion rows. A logical OR of the plurality of expansion rows produces a rotated square region of pixels. This rotated square region is then translated along an X and Y-axis and placed into a rotated image data buffer. One aspect of the invention is that the image data buffer may comprise a display buffer used to refresh an LCD display.
The CPU operates on an entire row of pixels, not a pixel at a time. Individual pixels need not be converted to byte values. This results in improved efficiency in performing the screen rotation. Because of the improved efficiency, there is less demand for CPU cycles and power, allowing the Palm-size PC to operate longer on a given set of batteries.